<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
    String contextPath = request.getContextPath();
    String groupId = request.getParameter("tabId");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>子系统管理</title>
<jsp:include page="/inc/inc.jsp" />
<script type="text/javascript">
var action = 'dataSourseAction';
var appId = "";
$(function(){	
	loadMtree();
	load();

	var saveForm = function(){
		var validate = $('#data').form('validate');
		if(validate){
		$.ajax({
			url:action+".do?method=save",
			data:{obj:$("#data").form2json()},
			dataType:'json',
			type:'post',
			success:function(data){
				if(data==true){
					alertInfo('保存成功！');
				}
				else{
					alertError('保存失败！');
				}
			}
		});
		}else{
			return validate;
		}
	};
	$('#saveBtn').click(saveForm);
});


var load=function(){
	$.ajax({
		url: action+'.do?method=load',
		type: 'post',
		data:{appId:appId},
		dataType:'json',
	    success: function(data){
	    	$('#data').form('load',data);
	    }
	});
};


var loadMtree = function(){
	  var setting = {	            
	            data: {
	                    simpleData: {
	                            enable: true,
	                            idKey: "id",
	                           // pIdKey: "pId",
	                            rootPId: 0
	                    }
	            },
	            async: { 
	                    type: "post",
	                    enable: true,
	                    url: 'dataSourseAction.do?method=getRightTrees',
	                    otherParam: {},
	            },
	            callback : {
	                onClick: function(event,treeId,node){
	                	appId=node.id;
	    				load();
	                }
	            },

	    };
	    $.fn.zTree.init($("#mtree"), setting);//初始化树对象a
};

function save(){
	if(appId==""){
		alertError("请选择对应子系统!");
		return;
	}
	$.ajax({
		url:'<%=contextPath%>/'+action+'.do?method=save',
		type: 'post',
	    data:{
	    	//ids:getChecked(),
	    	appId:appId
	    },
	    dataType: 'json',
	    error: function(){
	        alertErr('授权失败!');
	    },
	    success: function(data){
	    	alertInfo('授权成功!');
	    }
	});
}
</script>
</head>
<body class="easyui-layout">
	<div region="west" border="true" title="子系统" class="cs-west" style="width:180px;height: 100%" border="false">
		<ul id="mtree"  class='ztree'></ul>
	</div>
	<div  region="center" border="true" border="false" style="height:100%">
		<form id="data" method="post">
    	<input type="hidden" id="id" name="id" />
	    <table width="100%" align="left" class="tableForm">
	    	<tr><td>&nbsp;</td><td></td><td></td></tr>
	    	<tr><td>&nbsp;</td><td></td><td></td></tr>
			<tr>
				<td align="right" width="15%">
		    		子系统：
		    	</td>
				<td>
					<select id="appId" name="appId"  required="true" valueField="id" textField="name" class="easyui-combobox" style="width:155px;" url="dataSourseAction.do?method=getRightTrees">
					</select>
				</td>
				<td width="30%"></td>
			</tr>
			<tr>
				<td align="right" width="15%">
		    		连接名：
		    	</td>
				<td>
					<input type="text" id="conName" name="conName" required="true" style="width:320px;" class="easyui-validatebox"/>
				</td>
				<td width="30%"></td>
			</tr>
		    <tr>
		    	<td align="right">
		    		数据库类型：
		    	</td>
				<td>
					<select id="dbType" name="dbType"  required="true" valueField="id" textField="text" class="easyui-combobox" style="width:155px;" url="dataSourseAction.do?method=getCombobox&key=dm_sys_dbtype"> 
					</select>
				</td>
				<td></td>
		    </tr>
			<tr>
				<td align="right">
		    		数据库驱动：
		    	</td>
				<td>
					<input type="text" id="driver" name="driver" required="true" style="width:320px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		Hibernate方言：
		    	</td>
				<td>
					<input type="text" id="hibntype" name="hibntype" required="true" style="width:320px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		数据库名：
		    	</td>
				<td>
					<input type="text" id="dbname" name="dbname" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		用户名：
		    	</td>
				<td>
					<input type="text" id="user" name="user" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		密码：
		    	</td>
				<td>
					<input type="password" id="pwd" name="pwd" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		连接池初始化：
		    	</td>
				<td>
					<input type="text" id="initialNum" name="initialNum" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		连接池最小数：
		    	</td>
				<td>
					<input type="text" id="minIdle" name="minIdle" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		连接池最大数：
		    	</td>
				<td>
					<input type="text" id="maxActive" name="maxActive" required="true" style="width:120px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr>
				<td align="right">
		    		连接串：
		    	</td>
				<td>
					<input type="text" id="linkStr" name="linkStr" required="true" style="width:700px;" class="easyui-validatebox"/>
				</td>
				<td></td>
			</tr>
			<tr align="center">
				<td colspan="2">
					<a id='saveBtn' class="easyui-linkbutton" plain="true" iconCls="icon-save">保存</a>
				</td>
				<td></td>
			</tr>
		</table>
    </form>
		</div>
	</div>
</body>
</html>